package com.example.community.list;

import com.example.community.dao.ParkingDao;
import com.example.community.model.Parking;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@WebServlet(urlPatterns = "/hscw")
public class HscwServlet extends HttpServlet {
    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        String pno = req.getParameter("pno");
        ParkingDao parkingDao = new ParkingDao();
        Parking parking = parkingDao.fandById(Integer.parseInt(pno));
        parking.setUsNo(null);
        Integer update = parkingDao.update(parking);
        if (update == 1){
            resp.getWriter().write("true");
        }else {
            resp.getWriter().write("false");
        }

    }
}
